home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1992 August / info-mac-1992.iso / Language (lang) / GCC / GCC 1.37.1r7(Min) / Documents / Using GCC < prev   
Encoding:
Text File  |  1990-11-20  |  5.8 KB  |  124 lines  |  [TEXT/MPS ]

  1. This GCC port has been designed to fit as smoothly as possible into the MPW
  2. environment.  Once GCC has been installed, you need only change the name of
  3. the C compiler from "C" to "gC".  All of the usual MPW include files and libraries
  4. should work exactly the same as with MPW C; please let me know when they don't!
  5.  
  6. (MPW 3.2 NOTE:  3.2 has made incompatible changes in its includes/libraries that
  7. cause serious problems for GCC - see below for some ideas of what to do about this.)
  8.  
  9. There are some known differences between GCC and MPW C:
  10.  
  11. * Some MPW C options are not implemented by GCC.  See GCC.Help for the exact list
  12. of what is available.
  13.  
  14. * The dump and load pragmas are not supported.  Their presence will
  15. not cause an error however.
  16.  
  17. * The preprocessor symbol __DUMP__ is always undefined.
  18.  
  19. * The preprocessor symbol __SEG__ cannot be used to set the segment.
  20.  
  21. * The preprocessor symbol "mpwgcc" is defined.
  22.  
  23. * The "comp" type is recognized and has code generated for it, but the
  24. library routines are presently undefined.
  25.  
  26. * -sym options are just passed on to the MPW assembler, so SADE won't be that
  27. useful with your C source code.
  28.  
  29. * Since GCC produces code that is processed by the MPW Assembler, any C symbols
  30. that are the same as the names of 68xxx registers (d0, sp, caar, etc) must be
  31. changed to something else.  GCC will postpend a _ and issue a warning that this
  32. is being done.  If all of your program is being compiled by GCC, there shouldn't
  33. be any problems, but if you mix MPW C and GCC code, then you will get linker
  34. errors, and must modify your source code to use different symbols.
  35.  
  36. * A number of MPW bugs and sloppinesses are missing from GCC.  Although this is
  37. generally good, you may find that GCC complains about a number of situations that
  38. MPW accepts silently (and sometimes incorrectly!).
  39.  
  40. * A common instance of this is when GCC complains about
  41.   void foo(short); ... void foo(x) short x; { ... }
  42. This really is incorrect code, but MPW won't complain.  GCC has been changed to
  43. only issue a warning rather than an error in these cases, but you can expect to
  44. see a lot of these.
  45.  
  46. ADDITIONAL FEATURES OF GCC
  47.  
  48. There are dozens of additional options and features in GCC, which I will only
  49. summarize here.  See the GCC.Help file and the GCC manual for full descriptions.
  50. Also, the Commando interface is a convenient tour of all the command options.
  51.  
  52. Additional language constructs include statements and declarations inside of
  53. expressions, named expression type, typeof, alignof, generalized lvalues, arrays of
  54. variable length, nonconstant initializers, constructor expressions, function
  55. inlining, and inline assembly code.  Note that these nice new constructs are
  56. not in MPW C, which will usually fail on them; the gC option -pedantic will
  57. issue warnings when any of these appear in your code.
  58.  
  59. Additional GCC options include the ability to generate assembly language output,
  60. optional optimization, a number of controls over warning messages, and a number of
  61. controls over compilation technique.
  62.  
  63. Optimization in GCC is extremely good.  On the 680x0, GCC will do excellent
  64. register allocation, in addition to maximally exploiting addressing modes.
  65. (A dramatic example is the inner loop of Mandelbrot calculation - GCC will use
  66. all eight FPx registers for temporaries.)  It does tend to favor code speed
  67. over size.  Some parts of the Mac interface are done awkwardly and/or slowly
  68. (such as non-68881 SANE calls and pascal returns).
  69.  
  70. USING C++
  71.  
  72. The script gCPlus is an approximate implementation of MPW C++.  It works by
  73. running CFront with options set to produce text output, then invoking gC on
  74. the result.  MPW C++ and C++ in general are moving targets, so you're more likely
  75. to run into incompatibilities and other problems (static constructors and
  76. destructors are sometimes a hassle, for instance).
  77.  
  78. FURTHER READING
  79.  
  80. Both the compiler and preprocessor have their own manuals, which are in TeX
  81. format.  The installation document describes ways to get them into printed form.
  82.  
  83. The most useful parts are those describing the extra command options in detail
  84. (since the manual was written for Unix GCC, many of the option names are different,
  85. so watch out), and the sections describing GCC's extensions to C.
  86.  
  87. IF gC CRASHES
  88.  
  89. When the compiler runs into trouble, it will generally calls fancy_abort, which goes
  90. into Macsbug.  "g" usually gets you back to MPW safely.  This should never occur for
  91. the standard compiler; please report any occurrences, ideally including the source
  92. file and command options responsible.  GCC may occasionally produce code that the
  93. MPW Assembler will choke on; again, this shouldn't happen and should be reported
  94. when it does.  As a convenience when this happens, gC will leave the asm file
  95. around rather than deleting it.
  96.  
  97. Known problems with GCC are listed in the file "BUGS".  Fixes and/or suggestions
  98. to solve any of these problems will be gratefully accepted and incorporated into
  99. future releases of MPW GCC.
  100.  
  101. USING GCC WITH MPW 3.2
  102.  
  103. GCC supports most of the changes appearing in 3.2, but the parameter #pragma is
  104. another story entirely.  Basically, 3.2 allows you to declare that a procedure
  105. uses a given set of registers for its arguments and result.  However, GCC is not
  106. set up to switch calling conventions on the fly, so it can't make use of the
  107. pragma.  This wouldn't be so bad, but MPW has also changed many of the standard
  108. include files to depend on this pragma for correct code generation.
  109.  
  110. What's a poor developer to do?  Here are some alternatives:
  111.  
  112. 1. Ignore MPW 3.2.  (It does have some nice improvements though.)
  113.  
  114. 2. Keep your 3.1 includes/libraries and use them instead of the 3.2 versions.
  115. The ambitious could even try to use both sets together, but this is tricky.
  116.  
  117. 3. Use the 3.2 includes, but avoid calling anything with a parameter pragma,
  118. perhaps putting all such calls into a separate file that will be compiled by MPW C.
  119.  
  120. 4. Fix GCC to understand parameter pragmas.  (We may try doing this ourselves.)
  121.  
  122.  
  123.  
  124.